getwd()
setwd("C:/Users/Ivy/Documents/R_meus docs")
esaligna<-read.table("esaligna.csv", header=T, sep=",", as.is=T)
head(esaligna)
str(esaligna)

#5.1

esaligna$ht=esaligna$ht*100
plot(esaligna$dap~esaligna$ht, xlab="altura(cm)", ylab="dap(cm)", main="Eucalyptus Saligna", bty="L", tck=0.05, font.axis=2.5, font.lab=2.5, font.main=2.5, col="blue")

#5.2

media=aggregate(esaligna$dap, by=list(esaligna$talhao),mean)
media
desvio=aggregate(esaligna$dap, by=list(esaligna$talhao),sd)
desvio
matriz=matrix(data=c("media"=media$x,"sd"=desvio$x, "talhao"=1:6),nrow=6,ncol=3)

matriz

par(mfrow=c(1,2))
boxplot(esaligna$dap~esaligna$talhao, main="a")
plot(matriz[,1], ylim=c(0,20),main="b", xlab="talhao", ylab="dap")
segments(matriz[,3], (matriz[,1]-matriz[,2]), matriz[,3], (matriz[,1]+matriz[,2]))


#5.3
getwd()
setwd("C:/Users/Ivy/Documents/R_meus docs")

exec3<-read.table("exercicio3.csv", header=T, sep=",", as.is=T)
exec3
par(mfrow=c(1,2))
plot(exec3$x1,exec3$y1, xlim=c(0.5,2.3), ylim=c(0,3), ylab="Euclidean distances", xlab="Log(Pacht size)(ha)",pch=17, bty="L")
text(2.2,3, "a")
model=lm(exec3$x1~exec3$y1)
abline(model)

boxplot(exec3$x2~exec3$y2, xaxt="n", yaxt="n", , ylim=c(0,3), outline=F)
par(tcl=0.5, bty="L")
axis(2,at=seq(0,3,0.5))  
par(mgp=c(3,2,0))
axis(1, at=c(1:6), label=c("Small", "Medium \n Edge", "Medium \n Interior", "Large \n Edge","Large \n Interior", "Control"))
text(x=c(1:5), y=rep(3,5), c("*", "*", "**", "*", "***"))
text(6,3, "b")
